package com.zhxh.nzpos.query;

import java.util.ArrayList;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhxh.nzpos.R;
import com.zhxh.nzpos.model.Member;
import com.zhxh.nzpos.model.Suppliers;

public class MemberListAdapter extends BaseAdapter {

	private ArrayList<Member> items;
	private LayoutInflater inflater;
	
	public MemberListAdapter(LayoutInflater inflater, ArrayList<Member> memberItems) {
		this.items = memberItems;
		this.inflater = inflater;
	}
	
	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		
		  Log.i("getView==", "3333333333333333333333333333");
		//if (convertView == null) {
			convertView = inflater.inflate(R.layout.member_query_item, null);
			holder = new ViewHolder();
			holder.cardnumber = (TextView) convertView.findViewById(R.id.cardnumber);
			holder.name = (TextView) convertView.findViewById(R.id.name);
			holder.cardid = (TextView) convertView.findViewById(R.id.cardid);
			holder.phone = (TextView) convertView.findViewById(R.id.phone);
			holder.date = (TextView) convertView.findViewById(R.id.date);
			holder.points = (TextView) convertView.findViewById(R.id.points);
			convertView.setTag(holder);
	//	} else {
	//		holder = (ViewHolder) convertView.getTag();
		//}
		
	  Member item = items.get(position);
	  Log.i("member==", item.getCardNumber());
	  Log.i("name==", item.getName());
	  Log.i("cardid==", item.getShfzID());
	  Log.i("date==", item.getModified()+"");
	  Log.i("phone==", item.getPhone());
	  Log.i("points==", item.getPoints()+"");
		if (item != null) {
			holder.cardnumber.setText(item.getCardNumber());
			holder.name.setText(item.getName());
			holder.cardid.setText(item.getShfzID());
			holder.date.setText(""+item.getModified());
			holder.phone.setText(""+item.getPhone());
			holder.points.setText(""+item.getPoints());
		}
		return convertView;
	}

	static class ViewHolder {
		TextView cardnumber;
		TextView name;
		TextView cardid;
		TextView phone;
		TextView points;
		TextView date;
	}
}
